﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace NetByDocker.Store.Npgsql
{
    public static class ServiceCollectionExtensions
    {
        public static void AddPgSqlDbContextService(this IServiceCollection serviceCollection, IConfiguration configuration)
        {
            var conn = configuration["DbConfig:Postgresql:ConnectionString"];
            Console.WriteLine($"数据库地址为：{conn}");
            serviceCollection.AddEntityFramework<OpenDbContext>(options =>
            {
                options.ConnectionString = conn;
                options.IsSnakeCaseNaming = true;
                options.Schema = "example";
            }, x => x.MigrationsHistoryTable("__EFMigrationsHistory", "example"));
        }
    }
}